home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00082_Script_SET BROWSER TOPICS < prev    next >
Text File  |  1996-03-28  |  6KB  |  199 lines

  1. -- ---------------------------------------------------------------
  2. -- Handler setDatabaseBrowserGlobals
  3.  
  4. on setDatabaseBrowserGlobals
  5.   setBrowserLineHeight
  6.   setNumVisibleTopics
  7.   setNumVisibleLines
  8.   setNumBrowsers
  9.   setCurrentBrowser(1)
  10.   initializeBrowserTopics
  11.   setNumberTopics
  12.   setNumbernumVisibleLines
  13.   setBrowserTopLine(1)
  14.   initializeMasterBrowserTopics
  15.   setTextLineHeight
  16. end
  17.  
  18. -- ---------------------------------------------------------------
  19. -- Handler setNumBrowsers sets the global variable
  20. -- numBrowsers to the number of fields storing the browser
  21. -- topics (since one is not always enough). It sets the variable,
  22. -- depending on the current mode.
  23.  
  24. on setNumBrowsers
  25.   global numBrowsers, mode
  26.   
  27.   if (mode = "index") then
  28.     set numBrowsers = 1
  29.   else if (mode = "media") then
  30.     set numBrowsers = 1
  31.   else if (mode = "search") then
  32.     set numBrowsers = 1
  33.   end if
  34. end
  35.  
  36. -- ---------------------------------------------------------------
  37. -- Handler setCurrentBrowser sets the global variable
  38. -- currentBrowser to the name of the browserTopics field that
  39. -- is currently being displayed in the onstage broswer.
  40.  
  41.  
  42. on setCurrentBrowser whichNumber
  43.   global currentBrowser, numBrowsers
  44.   
  45.   -- ERROR HANDLING
  46.   if (whichNumber > numBrowsers) then
  47.     set currentBrowser = 1
  48.   else -- update normally
  49.     set currentBrowser = whichNumber
  50.   end if
  51. end
  52.  
  53. -- ---------------------------------------------------------------
  54. -- Handler initializeBrowserTopics initializes the global variable
  55. -- browserTopics to the first subset of topics.
  56.  
  57. on initializeBrowserTopics
  58.   global browserTopics
  59.   
  60.   set browserTopics = the text of cast "browserTopics"
  61. end
  62.  
  63. -- ---------------------------------------------------------------
  64. -- Handler setBrowserTopics sets the global variable
  65. -- browserTopics to the given list of topics.
  66.  
  67. on setBrowserTopics whichTopics
  68.   global browserTopics
  69.   
  70.   set browserTopics = whichTopics
  71. end
  72.  
  73. -- ---------------------------------------------------------------
  74. -- Handler setNumberTopics sets the global variable numberTopics
  75. -- to the number of browser topics in the database by adding
  76. -- together the number of topics in each of the browserTopics
  77. -- fields.
  78.  
  79. on setNumberTopics
  80.   global numberTopics, numBrowsers, browserTopics
  81.   
  82.   -- browserTopics has a blank line at the end so subtract
  83.   -- 1 to get the number of topics
  84.   set numberTopics = (the number of lines in browserTopics - 1)
  85. end 
  86.  
  87. -- ---------------------------------------------------------------
  88. -- Handler setNumbernumVisibleLines sets the global variable
  89. -- numnumVisibleLines to the number of lines in all the browser
  90. -- fields.
  91.  
  92. on setNumbernumVisibleLines
  93.   global numnumVisibleLines, browserTopics
  94.   
  95.   -- browserTopics has a blank line at the end so subtract
  96.   -- 1 to get the number of topics
  97.   set numnumVisibleLines = numnumVisibleLines + the number of lines in browserTopics - 1
  98. end
  99.  
  100. -- ---------------------------------------------------------------
  101. -- Handler initializeMasterBrowserTopics initializes the global
  102. -- variable masterBrowserTopics to the global variable browserTopics.
  103. -- The variable masterBrowserTopics contains the current list of
  104. -- topics that appear in the browser and can be a subset of either
  105. -- all browser topics or of the search results.
  106.  
  107. on initializeMasterBrowserTopics
  108.   global masterBrowserTopics, browserTopics
  109.   
  110.   set masterBrowserTopics = browserTopics
  111. end
  112.  
  113. -- ---------------------------------------------------------------
  114. -- Handler setMasterBrowserTopics sets the global
  115. -- variable masterBrowserTopics to the given list of topics.
  116.  
  117. on setMasterBrowserTopics whichTopics
  118.   global masterBrowserTopics
  119.   
  120.   set masterBrowserTopics = whichTopics
  121. end
  122.  
  123. -- ---------------------------------------------------------------
  124. -- Handler setNumVisibleTopics sets the global variable
  125. -- numVisibleTopis to the number of topics that can appear in the
  126. -- browser
  127.  
  128. on setNumVisibleTopics
  129.   global numVisibleTopics, browser, browserLineHeight
  130.   
  131.   -- one less to always keep an empty line at the end
  132.   set numVisibleTopics = integer (((the height of sprite browser + (browserLineHeight - 1 ))/ browserLineHeight) - 1)
  133.   
  134. end
  135.  
  136. -- ---------------------------------------------------------------
  137. -- Handler setNumVisibleLines sets the global variable numVisibleLines
  138. -- to the number of lines that can appear in the browser.
  139.  
  140. on setNumVisibleLines
  141.   global numVisibleLines, numVisibleTopics
  142.   
  143.   -- numVisibleTopics*numLinesPerBrowserEntry+numVisibleTopics-1 is the number
  144.   -- of visible lines accounting for the empty line between entries
  145.   -- numVisibleLines = 19 in battlefield
  146.   set numVisibleLines = numVisibleTopics 
  147. end
  148.  
  149. -- ---------------------------------------------------------------
  150. -- Handler setBrowserTopLine sets the global variable
  151. -- browserTopLine to the given value
  152.  
  153. on setBrowserTopLine whichValue
  154.   global browserTopLine
  155.   
  156.   set browserTopLine = whichValue
  157. end
  158.  
  159. -- ---------------------------------------------------------------
  160. -- Handler setBrowserText sets the text of the onstage browser
  161. -- (field "browser").
  162.  
  163. on setBrowserText
  164.   global browserTopLine, numVisibleTopics, browserTopics
  165.   global numBrowsers, currentBrowser, browserTopics, numVisibleLines
  166.   
  167.   set lastLine = numVisibleLines + browserTopLine - 1
  168.   
  169.   set browserText = line browserTopLine to lastLine of browserTopics
  170.   
  171.   set the text of cast "browser" = browserText
  172.   put EMPTY into line (lastLine + 1) of cast "browser"
  173. end
  174.  
  175. -- ---------------------------------------------------------------
  176. -- Handler setBrowserTopicsToCurrentBrowser sets the global
  177. -- variable browserTopics to the current browserField
  178.  
  179. on setBrowserTopicsToCurrentBrowser
  180.   global currentBrowser, mode, browserTopics, mediaTopics
  181.   
  182.   if (mode = "index") then
  183.     setBrowserTopics(browserTopics)
  184.   else if (mode = "media") then
  185.     setBrowserTopics(mediaTopics)
  186.   end if
  187. end
  188.  
  189. -- ---------------------------------------------------------------
  190. -- Handler setTopicProperty sets the global variable topicProperty
  191. -- to the given property, (one of the properties of topics can
  192. -- have in the database, eg. "text", "picture"...). This is used
  193. -- for setting the more buttons.
  194.  
  195. on setTopicProperty whichProperty
  196.   global topicProperty
  197.   
  198.   set topicProperty = whichProperty
  199. end